@echo off
chcp 65001
echo "检查Node环境"
call node -v
IF %errorlevel% == 0 (
  echo "检查通过"
  GOTO :exec 
) ELSE ( GOTO :judge )

:judge
echo "你的电脑没有安装Node"
set /p flag="要去官网下载么? y/n:"
IF /i "%flag%" == "y" ( GOTO :openNode ) ELSE ( GOTO :close )

:openNode
start http://nodejs.cn/download/
GOTO :close

:close
PAUSE
EXIT

:exec
echo "检查依赖"
IF NOT EXIST node_modules (
  echo "未安装环境，开始安装..."
  npm i
  echo "环境安装完成，请退出然后再点一次我"
  PAUSE
) ELSE (
  echo "环境已安装，开始执行..."
  node app.js
)
PAUSE
EXIT